package com.bee.littlebeetravel.fragment;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bee.littlebeetravel.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import q.rorbin.badgeview.QBadgeView;


public class FriendNameListFragment extends Fragment {

    private Unbinder unbinder;
    @BindView(R.id.tv_fans)
    TextView tv_fans;
    @BindView(R.id.tv_follow)
    TextView tv_follow;
    @BindView(R.id.tv_bee_friend)
    TextView tv_bee_friend;

    QBadgeView qBadgeView_follow;
    QBadgeView qBadgeView_bee_friend;

    @OnClick({R.id.tv_fans, R.id.tv_follow, R.id.tv_bee_friend})
    public void click(View v) {
        switch (v.getId()) {
            case R.id.tv_fans:
                tv_fans.setBackgroundResource(R.drawable.corner_org5_left);
                tv_fans.setTextColor(getActivity().getResources().getColor(R.color.white));
                tv_follow.setBackgroundResource(R.drawable.corner_org5_bord_middle);
                tv_follow.setTextColor(getActivity().getResources().getColor(R.color.org500));
                tv_bee_friend.setBackgroundResource(R.drawable.corner_org5_bord_right);
                tv_bee_friend.setTextColor(getActivity().getResources().getColor(R.color.org500));
                qBadgeView_follow.setVisibility(View.VISIBLE);
                qBadgeView_bee_friend.setVisibility(View.VISIBLE);
                break;
            case R.id.tv_follow:
                tv_fans.setBackgroundResource(R.drawable.corner_org5_bord_left);
                tv_fans.setTextColor(getActivity().getResources().getColor(R.color.org500));
                tv_follow.setBackgroundResource(R.color.org500);
                tv_follow.setTextColor(getActivity().getResources().getColor(R.color.white));
                tv_bee_friend.setBackgroundResource(R.drawable.corner_org5_bord_right);
                tv_bee_friend.setTextColor(getActivity().getResources().getColor(R.color.org500));
                qBadgeView_bee_friend.setVisibility(View.VISIBLE);
                qBadgeView_follow.setVisibility(View.INVISIBLE);
                break;
            case R.id.tv_bee_friend:
                tv_fans.setBackgroundResource(R.drawable.corner_org5_bord_left);
                tv_fans.setTextColor(getActivity().getResources().getColor(R.color.org500));
                tv_follow.setBackgroundResource(R.drawable.corner_org5_bord_middle);
                tv_follow.setTextColor(getActivity().getResources().getColor(R.color.org500));
                tv_bee_friend.setBackgroundResource(R.drawable.corner_org5_right);
                tv_bee_friend.setTextColor(getActivity().getResources().getColor(R.color.white));
                qBadgeView_follow.setVisibility(View.VISIBLE);
                qBadgeView_bee_friend.setVisibility(View.INVISIBLE);
                break;
        }
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_name_list, container, false);
        unbinder = ButterKnife.bind(this, v);
        initBadgeView();
        return v;
    }

    public void initBadgeView() {
        qBadgeView_follow = new QBadgeView(getActivity());
        qBadgeView_follow.bindTarget(tv_follow).setBadgeNumber(-1).setGravityOffset(8, true).setShowShadow(false);
        qBadgeView_bee_friend = new QBadgeView(getActivity());
        qBadgeView_bee_friend.bindTarget(tv_bee_friend).setBadgeNumber(-1).setGravityOffset(8, true).setShowShadow(false);
    }


    @Override
    public void onDestroy() {
        super.onDestroy();
        if (unbinder != null) {
            unbinder.unbind();
        }
    }
}